package www.dashu.com.domain;

import www.dashu.com.domain.base.BaseVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.Formula;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Data
@Entity
@Table(name="c_product_attribute")
public class CProductAttribute extends BaseVo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("")
    @Id
    private Long id;

    @ApiModelProperty("商品属性分类")
    @Column(name = "product_attribute_category_id")
    private Long productAttributeCategoryId;

    @Formula("(select s.name from c_product_attribute_category s where s.id = product_attribute_category_id )")
    private String productAttributeCategoryName;

    @ApiModelProperty("属性名")
    @Column(name = "name")
    private String name;

    @ApiModelProperty("属性选择类型：0->唯一；1->单选；2->多选")
    @Column(name = "select_type")
    private Integer selectType;

    @ApiModelProperty("属性录入方式：0->手工录入；1->从列表中选取")
    @Column(name = "input_type")
    private Integer inputType;

    @ApiModelProperty("可选值列表，以逗号隔开")
    @Column(name = "input_list")
    private String inputList;

    @ApiModelProperty("排序")
    @Column(name = "order_num")
    private Long orderNum;

    @ApiModelProperty("所属商户")
    @Formula("(select s.name from sys_company s where s.id = company )")
    private String companyName;

    @Column(name = "company")
    private Long company;

    @ApiModelProperty("所属应用")
    @Formula("(select s.name from sys_app s where s.id = app_id )")
    private String appName;

    @Column(name = "app_id")
    private Long appId;

    @ApiModelProperty("创建时间")
    @Column(name = "create_time")
    private Date createTime;

    @ApiModelProperty("更新时间")
    @Column(name = "update_time")
    private Date updateTime;

    @Transient
    List<String> values;

    @Transient
    Object options;

    @Transient
    Long productId;


    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", productAttributeCategoryId=").append(productAttributeCategoryId);
        sb.append(", name=").append(name);
        sb.append(", selectType=").append(selectType);
        sb.append(", inputType=").append(inputType);
        sb.append(", inputList=").append(inputList);
        sb.append(", orderNum=").append(orderNum);
        sb.append(", company=").append(company);
        sb.append(", appId=").append(appId);
        sb.append(", createTime=").append(createTime);
        sb.append(", updateTime=").append(updateTime);
        sb.append("]");
        return sb.toString();
    }

}